package org.spamforces.web.frame;

import org.nocturne.main.Frame;
import org.spamforces.model.User;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

/**
 * @author Mike Mirzayanov
 */
public abstract class ApplicationFrame extends Frame {
    @Override
    public PrintWriter getWriter() {
        try {
            return new PrintWriter(
                    new OutputStreamWriter(getOutputStream(), "UTF-8")
            );
        } catch (UnsupportedEncodingException e) {
            throw new IllegalStateException(e);
        }
    }

    protected User getUser() {
        return getSession("user", User.class);
    }
}
